www.gusucode.com > VC免费界面库 AppFace应用实例-源码程序 > VC免费界面库 AppFace应用实例-源码程序/code/Samples/VC6/DemoDlg/DemoDlg.cpp

    // DemoDlg.cpp : Defines the class behaviors for the application.
// Download by http://www.NewXing.com

#include "stdafx.h"
#include "DemoDlg.h"
#include "DemoDlgDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDemoDlgApp

BEGIN_MESSAGE_MAP(CDemoDlgApp, CWinApp)
	//{{AFX_MSG_MAP(CDemoDlgApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDemoDlgApp construction

CDemoDlgApp::CDemoDlgApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDemoDlgApp object

CDemoDlgApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDemoDlgApp initialization

BOOL CDemoDlgApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	AfxInitRichEdit() ;
	//----------------------------
	//For AppFace
	//Load From resource
	m_af.Start("IDR_MATINURF_GTBASE",GTP_LOAD_RESOURCE,NULL,"MATINURF",NULL) ;

	PBYTE buf = NULL ;  // Only used for load URF from Memory

	//The bellow remark codes demostrate loading URF from memory block or disk file
/*
	CString str = m_pszHelpFilePath ;
	str = str.Left(str.ReverseFind(_T('\\')));
	str += _T("\\GtClassic.urf");

    //Load From File
	m_af.Start((LPSTR)(LPCTSTR)str) ;

	//Load From memory	
	try
	{
		CFile f ;
		if(f.Open(str,CFile::modeRead))
		{
			ULONG nSize = f.GetLength() ;
			if(nSize > 0 )
			{
				buf = new BYTE[nSize] ;
				if(buf)
				{
					if(f.Read(buf,nSize))
						m_af.Start(buf,GTP_LOAD_MEMORY,nSize,NULL,NULL) ;

				}
			}
			 
			f.Close() ;
		}
	}
	catch(...)
	{
	}	
*/
  //----------------------------

	CDemoDlgDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	//----------------------------
	//For AppFace
	if(buf) 
		delete [] buf ;
	
	m_af.Remove()  ;
	//----------------------------

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}